import {
	EditViewActionType,
	IEditViewAbility,
	IEditViewControllerParams,
	IEditViewModel,
	IEditViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取编辑视图输入参数
 *
 * @export
 * @return {*}
 */
export function useEditViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取编辑视图基础
 *
 * @export
 * @param {IEditViewModel} model 编辑视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useEditViewBasic(model: IEditViewModel, props: IParam) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 编辑视图行为
 *
 * @export
 */
export function useEditViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取编辑视图控制器输入参数
 *
 * @export
 * @param {IEditViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<EditViewActionType, IEditViewAbility>>} evt
 * @return {*}  {IEditViewControllerParams<EditViewActionType, IEditViewAbility>}
 */
export function useEditViewControllerParams(
	model: IEditViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<EditViewActionType, IEditViewAbility>>
): IEditViewControllerParams<EditViewActionType, IEditViewAbility> {
	return {
		...useViewControllerParams<IEditViewStore, IEditViewModel>(
			model,
			props,
			evt
		),
	};
}
